import Vue from 'vue'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import axios from 'axios'

// Vue(axios)
Vue.use(ElementUI);
Vue.config.productionTip = false
// axios.defaults.baseURL = 'https://127.0.0.1:8084/hotel'
axios.defaults.baseURL = 'http://113.44.252.17:8085/hotel'
axios.interceptors.request.use(config => {
  // console.log(config)
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})

axios.interceptors.request.use(config => {
  console.log(`请求URL: ${config.baseURL}${config.url}`)
  return config
}, error => {
  return Promise.reject(error)
})
axios.interceptors.response.use(response => {
  return response
}, error => {
  return Promise.reject(error)
})

Vue.prototype.$http = axios

new Vue({
  render: h => h(App),
}).$mount('#app')
